package com.csu.panel;

import com.csu.consts.UiConsts;

import javax.swing.*;
import java.awt.*;
import java.awt.geom.RoundRectangle2D;

public class SubInfoPanel_Medium extends JPanel {

    public JLabel label_title;
    public JLabel label_amount;
    public JLabel label_trend;
    public JLabel label_percent;



    public SubInfoPanel_Medium(){
        setBackground(Color.WHITE);
        setLayout(null);

        label_title = new JLabel();
        label_amount = new JLabel();
        label_trend = new JLabel();
        label_percent = new JLabel();
        JLabel[] labels = { label_title, label_amount, label_trend, label_percent };

        for( int i = 0; i < labels.length; i ++ ) {
            labels[i].setForeground(Color.BLACK);
            labels[i].setVerticalTextPosition(JLabel.TOP);
            labels[i].setHorizontalTextPosition(JLabel.LEFT);
            add(labels[i]);
        }

        label_title.setFont(UiConsts.FONT_SUB_TITLE);
        label_trend.setFont(new Font("American Typewriter", Font.BOLD, 30));
        label_percent.setFont(new Font("American Typewriter", Font.BOLD, 15) );
        label_percent.setForeground(new Color(26,175,138));
        label_amount.setFont(UiConsts.FONT_INFO_AMOUNT);

        label_trend.setText("↑");
        label_amount.setText("¥ 111.00");
//        label_percent.setVerticalAlignment(JLabel.CENTER);
        label_percent.setText("11.2%");


        label_title.setBounds(30, 20, 200, 25);
        label_trend.setBounds( 30, 55, 50, 40);
        label_amount.setBounds(70, 65, 150, 25);
        label_percent.setBounds( 230, 68, 150, 20 );

    }

    public void setTitle(String title){
        label_title.setText(title);
    }

    @Override
    public void paint(Graphics g){
        int fieldX = 0;
        int fieldY = 0;
        int fieldWidth = getSize().width;
        int fieldHeight = getSize().height;
        RoundRectangle2D rect = new RoundRectangle2D.Double(fieldX,fieldY,fieldWidth,fieldHeight,20,20);
        g.setClip(rect);
        super.paint(g);
    }

}
